package com.pacific.sign.biz.service;

import com.pacific.common.request.CommonRequest;
import com.pacific.common.response.CommonResponse;
import com.pacific.sign.biz.service.impl.GroupService;
import com.pacific.sign.biz.wrapper.CommonWrapper;
import com.pacific.sign.biz.wrapper.aop.LogAnnotation;
import com.pacific.sign.model.po.pac.mbg.PacHcGroup;
import com.pacific.sign.model.po.pac.request.PacHcGroupRequest;
import com.pacific.sign.model.po.pac.response.PacHcGroupResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by 1 on 2017/6/30.
 */
@Service
public class HcGroupServiceImpl extends CommonWrapper implements HcGroupService {

    @Autowired
    private GroupService groupService;

    @LogAnnotation("权限组查询")
    public CommonResponse<PacHcGroupResponse> query(CommonRequest<PacHcGroupRequest> request) {
        CommonResponse<PacHcGroupResponse> response = new CommonResponse<PacHcGroupResponse>();
        try {
            response.setResult(groupService.query(request.getRequestParam()));
            wrapper(response);
        } catch (Exception e) {
            wrapper(response, e);
        }
        return response;
    }

    @LogAnnotation("权限组新增")
    public CommonResponse<Integer> insert(CommonRequest<PacHcGroup> request) {
        CommonResponse<Integer> response = new CommonResponse<Integer>();
        try {
            response.setResult(groupService.insert(request.getRequestParam()));
            wrapper(response);
        } catch (Exception e) {
            wrapper(response, e);
        }
        return response;
    }

    @LogAnnotation("权限组更新")
    public CommonResponse<Integer> update(CommonRequest<PacHcGroup> request) {
        CommonResponse<Integer> response = new CommonResponse<Integer>();
        try {
            response.setResult(groupService.update(request.getRequestParam()));
            wrapper(response);
        } catch (Exception e) {
            wrapper(response, e);
        }
        return response;
    }

    @LogAnnotation("权限组删除")
    public CommonResponse<Integer> delete(CommonRequest<PacHcGroup> request) {
        CommonResponse<Integer> response = new CommonResponse<Integer>();
        try {
            response.setResult(groupService.delete(request.getRequestParam()));
            wrapper(response);
        } catch (Exception e) {
            wrapper(response, e);
        }
        return response;
    }

    @LogAnnotation("权限组id查询")
    public CommonResponse<PacHcGroup> queryById(CommonRequest<Integer> request) {
        CommonResponse<PacHcGroup> response = new CommonResponse<PacHcGroup>();
        try {
            response.setResult(groupService.selectById(request.getRequestParam()));
            wrapper(response);
        } catch (Exception e) {
            wrapper(response, e);
        }
        return response;
    }

    @LogAnnotation("权限组id查询")
    public CommonResponse<PacHcGroup> queryByCode(CommonRequest<String> request) {
        CommonResponse<PacHcGroup> response = new CommonResponse<PacHcGroup>();
        try {
            response.setResult(groupService.queryByCode(request.getRequestParam()));
            wrapper(response);
        } catch (Exception e) {
            wrapper(response, e);
        }
        return response;
    }
}
